﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Web_Lean : System.Web.UI.Page
{
    protected List<Train> ts;
    protected void Page_Load(object sender, EventArgs e)
    {
        //确定要显示的控件
        string pid = Request.QueryString["pid"];
        if (pid == null || pid.Equals("1"))
        {
            Panel1.Visible = true;
        }
        else if(pid.Equals("2"))
        {
            Panel2.Visible = true;
        }
        else if (pid.Equals("3"))
        {
            Panel3.Visible = true;
        }
        else if (pid.Equals("4"))
        {
            Panel4.Visible = true;
        }
        else if (pid.Equals("5"))
        {
            Panel5.Visible = true;
        }
        else if (pid.Equals("6"))
        {
            Panel6.Visible = true;
        }
        else if (pid.Equals("7"))
        {
            Panel7.Visible = true;
        }
        else if (pid.Equals("8"))
        {
            Panel8.Visible = true;
        }
        else if (pid.Equals("9"))
        {
            Panel9.Visible = true;
        }
        else if (pid.Equals("10"))
        {
            Panel10.Visible = true;
        }
        ///
        // 初始化
        ///
        CmsDataContext db = new CmsDataContext();
        //
        //培训通知
        //
        //setInit(Repeater3, GetTopicId("培训通知"), 6);
        var train = (from aT in db.Train where (aT.Started - DateTime.Now).Days >= 0 orderby aT.Registed descending select aT).Take(6);
        ts = train.ToList<Train>();

        var px2 = (from aA in db.Article where aA.Verified != null orderby aA.Published descending select aA).Take(6);
        Repeater3.DataSource = px2;
        Repeater3.DataBind();
    }
    protected string GetTopicID(string tName)
    {
        CmsDataContext db = new CmsDataContext();
        var t = from aT in db.Topic where aT.Name.Equals(tName) select aT;
        if (t.Count() != 0)
        {
            return t.First().ID;
        }
        else
        {
            return "";
        }
    }
}